package edu.gyc.hizyj.controller;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import edu.gyc.hizyj.model.Girl;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
public class GirlController{
    @RequestMapping("/")
    public Object hi(HttpSession session  ){
        Girl zyj=new Girl(1, "赵雨静", LocalDateTime.now(), "ls");
        Girl zmy=new Girl(2, "张曼玉", LocalDateTime.now(), "ls");
        Girl zhm=new Girl(3, "周慧敏", LocalDateTime.now(), "ls");
        session.setAttribute("lover", zyj);
        session.setAttribute("whore", zmy);
        session.setAttribute("sex", zhm);
        Enumeration<String> data= session.getAttributeNames();
        List<Girl> girls=new ArrayList<>();
        while(data.hasMoreElements()){
            Girl girl=(Girl)session.getAttribute(data.nextElement());
            girls.add(girl);
        }
        return girls;
    }

    @GetMapping("/lover")
    public Object lover(HttpSession session ){
        return session.getAttribute("lover");
    }

    @GetMapping("/sex")
    public Object sex(HttpSession session ){
        Girl girl=(Girl)session.getAttribute("lover");
        return "Tonight girl "+girl+" service you.";
    }
}